package com.admin.service.vo;

import com.admin.persistence.sys.entity.Person;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.stream.Collectors;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class SysPerson {

    private Person person;

    private List<SysUser> users;

    private List<SysUserGroup> userGroups;

    @Override
    public String toString() {
        String userStr = "", userGroupStr = "";
        if(!CollectionUtils.isEmpty(users)){
            userStr=users.stream().map(cur->{
              return   cur.toString();
            }).collect(Collectors.joining(",","[","]"));
        }
        if(!CollectionUtils.isEmpty(userGroups)){
            userGroupStr = userGroups.stream().map(cur->{
                return   cur.toString();
            }).collect(Collectors.joining(",","[","]"));
        }
        return "SysPerson{" +
                "person=" + person +
                ", users=[" + users +userStr+
                ", userGroups=" + userGroups +userGroupStr+
                '}';
    }
}
